<template>
	<view scroll-with-animation scroll-y :style="{paddingTop: statusBarHeight + 'px'}"
		style="height: 100%;position: relative;background-color: #FFFFFF;padding-top: 200rpx;">
		<view :style="{
				height: statusBarHeight + 'px',
				paddingTop: statusBartop + 'px'
			  }" style="width: 100%;position: fixed;top:0;left: 0;z-index: 999;
				color: #000000;display: flex;
				align-items: center;
				justify-content: center;
				background: #FFFFFF;box-sizing:border-box;">
			<view>邛崃民众门诊部</view>
			<view style="width: 100%;position:absolute;left:0rpx;display: flex;align-items: center;padding-left: 40rpx;"
				:style="{
					  top:statusBartop + 'px',
					  height: (statusBarHeight-statusBartop) + 'px'
				  }">
				<image style="height: 50%;" src="../../static/images/sys@2x.png" mode='heightFix' @click="smewm">
				</image>
				<view style="font-size: 20rpx;color: #424c4c;margin-left: 10rpx;">扫一扫</view>
			</view>
		</view>
		<!-- 内容 -->
		<view>
			<view style="width: 100%;text-align: center;position: relative;margin-bottom: 40rpx;">
				<image src="https://mzmzb.oss-cn-chengdu.aliyuncs.com/indexBanner.png" style="width: 100%;" mode="widthFix" @click="toOut">
				</image>
				<view
					style="width: 100%;height: 80rpx;position: absolute;bottom: -40rpx;background-color: #FFFFFF;border-top-left-radius: 90rpx;border-top-right-radius: 90rpx;">
					<view class="ml25 mr25 search flex flex-ac pl25 pr25" style="background-color: #FFFFFF;height: 80rpx;
						border:2rpx solid #EADBDD;border-radius: 40px;box-shadow: 0px 5px 25px 0px rgba(0,186,173,0.07);"
						@click="toSeach">
						<image src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/search.png"
							mode="widthFix"></image>
						<input class="it1" placeholder="搜医生、科室、症状" />
					</view>
				</view>
			</view>
			<!-- 展示医院数据 -->
			<view style="padding: 40rpx 20rpx 0 20rpx ;">
				<view style='display: flex;justify-content: space-around;'>
					<view style="color: rgba(87, 61, 34, 0.7);text-align: center;">
						<view style="display: flex;align-items: center;width: 20vw;justify-content: space-between;">
							<view>
								<view style="font-size: 36rpx;font-weight: 500">{{info.orderNum}}</view>
								<view style="font-size: 28rpx;font-weight: 400">预约</view>
							</view>
							<view style="border-right: 1rpx solid rgba(87, 61, 34, 0.2);height: 44rpx;"></view>
						</view>
					</view>
					<view style="color: rgba(87, 61, 34, 0.7);text-align: center;">
						<view style="display: flex;align-items: center;width: 20vw;justify-content: space-between;">
							<view>
								<view style="font-size: 36rpx;font-weight: 500">{{info.consultNum}}</view>
								<view style="font-size: 28rpx;font-weight: 400">咨询</view>
							</view>
							<view style="border-right: 1rpx solid rgba(87, 61, 34, 0.2);height: 44rpx;"></view>
						</view>
					</view>
					<view style="color: rgba(87, 61, 34, 0.7);text-align: center;">
						<view style="display: flex;align-items: center;width: 20vw;justify-content: space-between;">
							<view>
								<view style="font-size: 36rpx;font-weight: 500">{{info.fansNum}}</view>
								<view style="font-size: 28rpx;font-weight: 400">粉丝</view>
							</view>
							<view style="border-right: 1rpx solid rgba(87, 61, 34, 0.2);height: 44rpx;"></view>
						</view>
					</view>
					<view style="color: rgba(87, 61, 34, 0.7);text-align: center;">
							<view>
								<view style="font-size: 36rpx;font-weight: 500">{{info.visitNum}}</view>
								<view style="font-size: 28rpx;font-weight: 400">访问</view>
							</view>
					</view>
				</view>
			</view>
			<view class="" >
				<view class="row">
					<view class="card zxwz" @tap="toDoctorlist()">
						<view class="card-content">
							<view class="card-title">在线问诊</view>
							<view class="card-desc">线上问诊开方拿药</view>
						</view>
						<image class="card-img" mode="heightFix" src="https://mzmzb.oss-cn-chengdu.aliyuncs.com/zxwz.png"></image>
						<image class="card-bg" mode="heightFix" src="https://mzmzb.oss-cn-chengdu.aliyuncs.com/zxwzbg.png"></image>
					</view>
					<view class="card ffxz" @tap="tochufanglist()">
						<view class="card-content">
							<view class="card-title">复诊续方</view>
							<view class="card-desc">选择科室复诊拿药</view>
						</view>
						<image class="card-img" mode="heightFix" src="https://mzmzb.oss-cn-chengdu.aliyuncs.com/ffxz.png"></image>
						<image class="card-bg" mode="heightFix" src="https://mzmzb.oss-cn-chengdu.aliyuncs.com/ffxzbg.png"></image>
					</view>
				</view>
				<view class="row">
					<view class="card ynzj" @tap="toTjyf()">
						<view class="card-content">
							<view class="card-title">院内制剂</view>
							<view class="card-desc">一对一专业咨询</view>
						</view>
						<image class="card-img" mode="heightFix" src="../../static/images/ynzj.png"></image>
						<image class="card-bg" mode="heightFix" src="../../static/images/ynzjbg.png"></image>
					</view>
				
					<view class="card bgjd" @tap="toDoctorlistByUnscramble()">
						<view class="card-content">
							<view class="card-title">报告解读</view>
							<view class="card-desc">线上报告解读</view>
						</view>
						<image class="card-img" mode="heightFix" src="https://mzmzb.oss-cn-chengdu.aliyuncs.com/bgjd.png"></image>
						<image class="card-bg" mode="heightFix" src="https://mzmzb.oss-cn-chengdu.aliyuncs.com/bgjdbg.png"></image>
					</view>
				</view>
			</view>
			
			<view style="width: 100%;text-align: center;position: relative;margin-top: 24rpx;background: rgba(255, 255, 255, 1);box-shadow:2rpx 6rpx 16rpx rgba(0, 0, 0, 0.1);opacity: 1;">
				<swiper :style="{height:'200rpx'}" circular indicator-dots indicator-active-color="rgba(246, 189, 77, 1)">
					<swiper-item>
						<image class="swiper-img" src="https://mzmzb.oss-cn-chengdu.aliyuncs.com/fzlcbanner.png"
							style="width: 92%;border-radius: 15rpx;" mode="widthFix" @tap="toOut2()"></image>
					</swiper-item>
				</swiper>
			</view>
			
			<view class="" style="height:164rpx;background: rgba(255, 255, 255, 1);box-shadow:2rpx 6rpx 16rpx rgba(0, 0, 0, 0.1);opacity: 1;margin: 20rpx 0;padding: 0 20rpx;">
				<swiper style="height:164rpx;" circular vertical autoplay :interval="3000">
					<swiper-item v-for="(item,index) in newOrder" :key="index">
					<view style="display: flex;align-items: center;height: 164rpx;">
						<image :src="item.doctorPhoto" mode="widthFix" style="width: 92rpx;border-radius: 50%;"></image>
						<view class="">
							<view style="display: flex;align-items: center;">
							<view style="color: rgba(87, 66, 43, 1);font-size: 28rpx;font-weight: 700;">{{item.doctorName}}</view>
							<view class="">
							</view>
							<view style="font-size: 26rpx;font-weight: 400;">{{item.hspName}}</view>
							</view>
							<view style="display: flex;font-size: 26rpx;font-weight: 400;">
								<view style="color: rgba(138, 97, 28, 1);">{{item.orderTime}}</view>
								<view style="color: rgba(87, 66, 43, 0.6);">{{item.fileName}}</view>
								<view style="color:rgba(87, 66, 43, 1)">{{item.orderType}}</view>
							</view>
						</view>
					</view>
					</swiper-item>
				</swiper>
			</view>
			<view
				style="width: 100%;background-color: #FFFFFF;height: 350rpx;display: flex;align-items: center;justify-content: center;position: relative;">
				<view
				class="rmks"
					style="width: 85%;height: 90%;border-radius: 32rpx;display: flex;flex-direction: column;align-items: center;justify-content: space-around;padding: 10rpx 20rpx;">
					<view style="width: 100%;display: flex;align-items: center;justify-content: space-between;">
						<image src="../../static/images/rmks.png" mode="widthFix" style="width: 128rpx;"></image>
							<image src="../../static/images/gd.png" mode="widthFix" style="width: 128rpx;"></image>
					</view>
					<view style="width: 100%;display: flex;align-items: center;">
						<view v-for="(deptItem,deptIdx) in deptList"
							style="width: 20%;display: flex;flex-direction: column;align-items: center;"
							@tap="toDoctorlistByDept(deptItem)" :key="deptIdx">
							<view
								style="height: 16vw;width: 16vw;border-radius: 50%;
								background-color: #FFFFFF;box-shadow: 0rpx 5rpx 10rpx 0rpx rgba(0,186,173,0.0700);display: flex;align-items: center;justify-content: center;">
								<image src="../../static/images/zyk.png" style="width: 50%;" mode="widthFix"></image>
							</view>
							<view
								style="width: 100%;text-align: center;margin-top: 10rpx;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;">
								{{deptItem.name}}
							</view>
						</view>

					</view>
				</view>
			</view>
			<view class="pl25 pr25 box" id="sticky-nav"
				style="border-top-left-radius: 32rpx;;border-top-right-radius:32rpx;background-color: #FFFFFF;margin-top: 40rpx;">
				<view
					style="width: 100%;display: flex;align-items: center;justify-content: space-between;margin-bottom: 20rpx;">
					<image src="../../static/images/zjtj.png" mode="widthFix" style="width:128rpx"></image>
					<image src="../../static/images/gd.png" mode="widthFix" style="width: 128rpx;" @tap="toDoctorlist()"></image>
				
				</view>
			</view>
			<view class="list pl25 pr25" style="text-align: center;background: rgba(255, 255, 255, 1);box-shadow: 2rpx 10rpx 26rpx  rgba(141, 101, 31, 0.1)">
				<view v-for="(item,index) in docList" :key="index" @click="getDocInfo(item.id,item.recNum)"
					style="border: 1px solid #F2F9F9;box-shadow: 0px 1px 17px 1px rgba(162, 215, 211, 0.16);border-radius: 32rpx;margin-bottom: 20rpx;">
					<view class="flex" style="padding-left: 20rpx;box-sizing: border-box;padding-right: 25rpx;">
						<view class="rela head">
							<image :src="item.photo"></image>
							<view class="w100 abs texts ftc cfff" v-if="item.onlineState==8"><text class="text3"
									style="background: rgba(138, 97, 28, 1)">接诊</text></view>
							<view class="w100 abs texts ftc cfff" v-if="item.onlineState==0"><text
									class="text3">离线</text></view>
							<view class="w100 abs texts ftc cfff" v-if="item.onlineState==7"><text class="text3"
									style="background: rgba(240, 224, 197, 1)">休息</text></view>
							<view class="w100 abs texts ftc cfff" v-if="item.onlineState==6"><text
									class="text3">离开</text></view>
							<view>
								<text class="ft16 c000 bold">{{item.name}}</text>
							</view>
						</view>
						<view class="it1 pl30">
							<view class="mt25 flex flex-ac flex-pc">
								<view class="it1 flex flex-ac doctor">
									<view class="doctorv" v-if="item.ismessage==1"
										style="display: flex;align-items: center;">
										<image src="../../static/images/tuwen.png" style="width: 50rpx;"
											mode="widthFix"></image>
										<text style="color: rgba(87, 66, 43, 1);">¥{{' '+item.messagefee}}</text>
									</view>
									<view class="doctorv" v-if="item.ismessage==0"
										style="display: flex;align-items: center;">
										<image src="../../static/images/wkttw.png" style="width: 50rpx;"
											mode="widthFix"></image>
										<text style="color: rgba(87, 66, 43, 1);">未开通</text>
									</view>
									<view class="doctorv" v-if="item.isvideo==1"
										style="display: flex;align-items: center;">
										<image src="../../static/images/wkttw.png" style="width: 50rpx;"
											mode="widthFix"></image>
										<text style="color: rgba(87, 66, 43, 1);">¥{{' '+item.videofee}}</text>
									</view>
									<view class="doctorv" v-if="item.isvideo==0"
										style="display: flex;align-items: center;">
										<image src="../../static/images/wkttw.png" style="width: 50rpx;"
											mode="widthFix"></image>
										<text style="color: rgba(87, 66, 43, 1);">未开通</text>
									</view>
								</view>
							</view>
							<view class="flex flex-ac" style="color: rgba(87, 66, 43, 1);">
								<view style="font-weight: 600">{{item.deptName}}</view>
								<text class="ml30">{{item.title}}</text>
							</view>
							<view class="lineText3 mt20" style="text-align: left;color: rgba(87, 66, 43, 1)">擅长：{{item.disease}}
							</view>
						</view>
					</view>
					<view style="display: flex;justify-content: center;margin-top: 40rpx;">
						<view
							style="width: 90%;border-top: 2rpx solid #E6EAEA;padding-top: 20rpx;display: flex;align-items: center;justify-content: space-around;">
							<view>已服务：<text style="color: rgba(246, 189, 77, 1)">{{item.recNum}}人</text></view>
							<view>接诊率：<text style="color: rgba(246, 189, 77, 1)">100%</text></view>
							<view>平均回复：<text style="color: rgba(246, 189, 77, 1)">1小时</text></view>
						</view>
					</view>
				</view>

				<uni-load-more :status="message" :contentText="contentText" @clickLoadMore="loadMore"></uni-load-more>
			</view>
		</view>
		<view style="text-align: center;font-size: 10px;" v-if="statusOne">由重庆拓诊信息技术有限公司提供技术支持</view>
		<view class="win flex" v-if="getUserWin" @touchmove.stop="">
			<view
				style="margin: auto;background-color: #FFFFFF;border-radius: 20rpx;width: 90%;height: 400rpx;display: flex;flex-direction: column;align-items: center;justify-content: space-around;">
				<view style="font-size: 38rpx;text-align: center;font-weight: bolder;">温馨提示</view>
				<view style="font-size: 34rpx;text-align: center;">您尚未登录，请先登录...</view>
				<button class='login_btn'
					style="background-color: #F28C87;border-radius: 50rpx;width: 300rpx;height: 100rpx;line-height: 100rpx;"
					type='primary' open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
					立即登录
				</button>
			</view>
		</view>
		<view class="win flex" v-if="getUserHead" @touchmove.stop="">
			<view
				style="margin: auto;background-color: #FFFFFF;border-radius: 20rpx;width: 80%;height: 400rpx;display: flex;flex-direction: column;align-items: center;justify-content: space-around;">
				<view style="font-size: 36rpx;text-align: center;font-weight: bold;">获取昵称</view>
				<view style="font-size: 30rpx;text-align: center;">是否同意获取微信昵称？</view>
				<view
					style="display: flex;flex-direction: row;align-items: center;justify-content: space-around;align-items: center;width: 100%;">
					<button type='primary'
						style="background-color: #F3F3F3;width: 40%;color: #000000;height: 90rpx;line-height: 90rpx;font-size: 30rpx;"
						@click="getUserHead=false">
						取消
					</button>
					<button type='primary'
						style="background-color: #F28C87;width: 40%;height: 90rpx;line-height: 90rpx;font-size: 30rpx;"
						@click="wxGetUserInfo">
						确定
					</button>
				</view>
			</view>
		</view>
		<view class="win flex" v-if="getSubscribe" @touchmove.stop="">
			<view
				style="margin: auto;background-color: #FFFFFF;border-radius: 20rpx;width: 80%;height: 400rpx;display: flex;flex-direction: column;align-items: center;justify-content: space-around;">
				<view style="font-size: 36rpx;text-align: center;font-weight: bold;">订阅消息</view>
				<view style="font-size: 30rpx;text-align: center;">确认订阅消息？</view>
				<view
					style="display: flex;flex-direction: row;align-items: center;justify-content: space-around;align-items: center;width: 100%;">
					<button type='primary'
						style="background-color: #F28C87;width: 40%;height: 90rpx;line-height: 90rpx;font-size: 30rpx;"
						@click="getrequestSubscribeMessage">
						确定
					</button>
				</view>
			</view>
		</view>
		<uni-popup ref="popup" type="message">
			<uni-popup-message :type="warnType" :message="warnMessage" :duration="warnTime"></uni-popup-message>
		</uni-popup>
		<CustomTabBar  current="/pages/index/index" />
	</view>
</template>

<script>
	const WxAuth = require('@/utils/wxlogin');
	import CustomTabBar  from '@/components/CustomTabBar/index.vue';
	export default {
		components: { CustomTabBar } ,
		data() {
			return {
				newOrder:[],
				info: {},
				deptList: [],
				warnMessage: '错误', //消息内容
				warnType: 'warn', //消息类型  success/warn/info/error
				warnTime: 1000, //消息提醒延长时间
				isLogin: false,
				getUserWin: false,
				getUserHead: false,
				getSubscribe: false,
				statusOne: false,
				usrUserId: null,
				wx: "https://app.mzmzb.com", //https://app.mzmzb.com   http://localhost:6110
				winState: false,
				animation: null,
				animationData: null,
				windowWidth: 0,
				hospitalId: null,
				current: 1,
				docList: [],
				baselnfoList: [],
				code: "",
				encryptedData: "",
				iv: "",
				openId: "",
				sessionKey: "",
				nickName: "",
				avatarUrl: '../../static/images/mrtx.png',
				isCanUse: uni.getStorageSync('isCanUse'), //默认为true  记录当前用户是否是第一次授权使用的
				message: 'more',
				contentText: {
					contentdown: "点击显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多数据了"
				},
				hasNextPage: true, //是否有下一页
				baseDeptId: 0, //科室ID
				deptDocList: [],
				deptCurrent: 1,
				allDocList: [],
				notice: '',
				statusBarHeight: 0,
				statusBartop: 0,
				swiperHeight: 0
			};
		},
		onShareAppMessage() {
			return {
				title: '邛崃民众门诊部'
			}
		},
		onShareTimeline() {
			return {
				title: '邛崃民众门诊部'
			}
		},
		onLoad() {
			// uni.getSystemInfo(OBJECT)
			// console.log("_this.onLoad==================")
			let _this = this;
			uni.getSystemInfo({
				success: function(res) {
					_this.windowWidth = res.windowWidth
					const custom = wx.getMenuButtonBoundingClientRect()
					// customBar = custom.bottom + custom.top - e.statusBarHeight
					_this.statusBarHeight = custom.bottom + custom.top - res.statusBarHeight
					_this.statusBartop = res.statusBarHeight
					console.log('statusBarHeight', _this.statusBarHeight);
				}
			})
			//初始化一个动画
			var animation = uni.createAnimation({
				duration: 500,
				timingFunction: 'ease',
			})
			this.animation = animation;
			// 定义动画内容getDocList
			this.animation.translateX(_this.windowWidth).step()
			// 导出动画数据传递给data层
			this.animationData = this.animation.export();
			this.getDocList();
			this.getHspNoticeList();
			this.getHspDeptList();
			this.getBaselnfoList();
			let userId = uni.getStorageSync("usrUserId");
			// console.log("_this.userId==================",userId)
			if (userId) {
				let isAccredit = false

				this.isLogin = true
				this.usrUserId = uni.getStorageSync("usrUserId");
				this.loginHX(userId)
				let avatarUrl = uni.getStorageSync("avatarUrl");
				let nickName = uni.getStorageSync("nickName");
				if (avatarUrl && nickName) {
					this.avatarUrl = avatarUrl
					this.nickName = nickName
				} else {
					// WxAuth.onLogin()
					// setTimeout(()=>{
					// 	this.getUserWin = true
					// },500)
				}
			} else {
				// WxAuth.onLogin()
				// setTimeout(()=>{
				// 	this.getUserWin = true
				// },500)
			}
			this.getCharList()
			this.getElementHeight('.swiper-img')
			this.getxz()
			this.getNewOrder()
		},
		onShow() {
			WxAuth.onLogin()
			let userId = uni.getStorageSync("usrUserId");
			if (userId) {
				this.isLogin = true
				this.usrUserId = uni.getStorageSync("usrUserId");
				// this.loginHX(userId)
				let avatarUrl = uni.getStorageSync("avatarUrl");
				let nickName = uni.getStorageSync("nickName");
				if (avatarUrl && nickName) {
					this.avatarUrl = avatarUrl
					this.nickName = nickName
					this.getUserWin = false
				}
			}
		},
		//下拉刷新
		onPullDownRefresh() {
			var that = this;
			that.docList = [];
			that.allDocList = [];
			that.deptDocList = [];
			that.current = 1;
			that.baseDeptId = 0;
			console.log("当前页:" + that.current)
			console.log("科室ID:" + that.baseDeptId)
			that.getDocList()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 500);
		},
		onReachBottom() {
			this.statusOne = true
		},
		methods: {
			getNewOrder(){
				uni.request({
					url: 'https://app.mzmzb.com/application-usrapp/mzmzb/lastOrders.tz?hspId=23840',
					method: 'GET',
					success: (res) => {
						console.log(res, '新增')
						this.newOrder = res.data.result
					}
				})
			},
			getxz() {
				uni.request({
					url: 'https://app.mzmzb.com/application-usrapp/mzmzb/visitStatistics.tz?hspId=23840',
					method: 'GET',
					success: (res) => {
						this.info = res.data.result
					}
				})
			},
			getElementHeight(element) {
				setTimeout(() => {
					let query = uni.createSelectorQuery().in(this);
					query.select(element).boundingClientRect();
					query.exec((res) => {
						if (!res) { //如果没获取到，再调一次
							this.getElementHeight();
						} else {
							this.swiperHeight = res[0].height;
						}
					})
				}, 200)
			},
			//格式化时间
			changeDateFormat(cellval) {
				if (cellval) {
					var dateVal = cellval + "";
					if (cellval != null) {
						var date = new Date(parseInt(dateVal.replace("/Date(", "").replace(")/", ""), 10));
						var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
						var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
						var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
						var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
						var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
						return date.getFullYear() + "-" + month + "-" + currentDate + " " + hours + ":" + minutes;
					}
				}
			},
			toOut1() {
				uni.navigateTo({
					url: '/pages/index/html'
				});
			},
			toOut2() {

				uni.navigateTo({
					url: '/pages/out/img'
				});
			},
			getCharList() {
				let userId = uni.getStorageSync("usrUserId");
				if (!userId || userId.length < 1) {
					return
				}
				this.func.$request('wx/selectChatListNumber.tz', {
					receive: userId
				}, 'GET').then(res => {
					if (res.data.success) {
						let count = res.data.result;
						this.noReadNum = count
						if (count > 0) {
							uni.setTabBarBadge({
								index: 1,
								text: count.toString()
							})
						} else {
							uni.removeTabBarBadge({
								index: 1
							})
						}
					}

				})

			},
			getrequestSubscribeMessage() {
				this.getSubscribe = false
				uni.requestSubscribeMessage({
					tmplIds: ['1JlcLdsSeS3bTUhfYkUjzB0Ts1XWbn3A7C7BHqWSxEg',
						'ZsHYJ0dSyZE-AvmQ8ohFB18PpP-ak8bw46zhEFvDwLk'
					],
					success: (res) => {
						console.log('订阅success', res)
					},
					fail: (res) => {
						console.log('订阅fail', res)
					}
				})
			},
			toSeach() {
				var that = this;
				uni.navigateTo({
					url: '/pages/search/index?usrUserId=' + that.usrUserId
				})
			},
			// toOut(){

			// 	var that = this;
			// 	uni.navigateTo({
			// 		url: '/pages/out/out'
			// 	})
			// },
			smewm() {
				uni.scanCode({
					success: (res) => {
						let codeStr = res.result
						let docId = codeStr.substring(codeStr.indexOf('=') + 1)
						// console.log('条码内容：docId = ' + docId);
						uni.request({
							url: this.wx + '/application-usrapp/scanEstablishFriend.tz',
							method: 'POST',
							data: {
								docId: docId,
								usrId: this.usrUserId
							},
							header: {
								'content-type': 'application/x-www-form-urlencoded'
							},
							success: (res) => {
								if (res.data.success = true) {
									uni.showToast({
										title: res.data.errMsg,
										icon: 'success'
									})
								}
							}
						})
					}
				})
			},
			toggao() {
				uni.navigateTo({
					url: '/pages/gonggao/index'
				});
			},
			getxxxq(xxid) {
				let infos = this.baselnfoList.filter(item => item.id = xxid)
				uni.setStorageSync('xxinfo', infos[0])
				uni.navigateTo({
					url: '/pages/xxxq/index'
				});
			},
			//档案信息跳转
			recordNavigateTo() {
				if (this.usrUserId) {
					uni.navigateTo({
						url: '/pages/record/index?userId=' + this.usrUserId
					});
				} else {
					this.getUserWin = true
				}
			},
			//登录
			getPhoneNumber(e) {
				var that = this;
				if (e.detail.errMsg == "getPhoneNumber:ok") {
					that.encryptedData = e.detail.encryptedData;
					that.iv = e.detail.iv;
					that.getCode(e.detail.encryptedData, e.detail.iv, this.hspId);
				}
			},
			//获取用户id并存入缓存
			getCode(encryptedData, iv, hspId) {
				var that = this;
				WxAuth.checkSession().then(code => {
					console.log('getCode=============1', code)
					WxAuth.getUserIdByPhone(code, encryptedData, iv, hspId).then(res => {
						console.log('getCode=============2', res)
						if (res.success) {
							that.warnMessage = '登录成功';
							that.warnType = 'success';
							that.$refs.popup.open();
							// that.loginHX(res.result);//登录环信
							that.getUserWin = false
							that.isLogin = true
							that.usrUserId = res.result;
							this.getUserHead = true
							uni.login({
								provider: 'weixin',
								success: (loginres) => {
									if (loginres.errMsg == "login:ok") {
										that.getOpenIdByHspId(loginres.code)
										// that.getSubscribe = true
										wx.getSetting({
											withSubscriptions: true,
											success(res) {
												var itemSettings = res
													.subscriptionsSetting.itemSettings
												if (itemSettings) {
													if (itemSettings[
															'1JlcLdsSeS3bTUhfYkUjzB0Ts1XWbn3A7C7BHqWSxEg'
														] === 'accept' &&
														itemSettings[
															'ZsHYJ0dSyZE-AvmQ8ohFB18PpP-ak8bw46zhEFvDwLk'
														] === 'accept') {
														that.getSubscribe = false
													} else {
														that.getSubscribe = true
													}
												} else {
													that.getSubscribe = true
												}
											},
											fail(res) {
												that.getSubscribe = true
											}
										})
									}
								}
							});

						} else {
							that.warnMessage = res.errMsg;
							that.warnTime = 2000;
							that.$refs.popup.open();
						}

					})
				});
			},
			getOpenIdByHspId(code) {
				uni.request({
					url: this.wx + '/application-usrapp/wx/getOpenIdByHspId.tz',
					method: 'get',
					data: {
						code: code,
						userId: this.usrUserId,
						hspId: this.hspId
					},
					success: (res) => {

					}
				})
			},
			toOut() {
				uni.navigateTo({
					url: '/pages/out/out'
				});
			},
			toDoctorlistByDept(val) {
				console.log(val)
				uni.navigateTo({
					url: '/pages4/doctorlist/index?deptId=' + val.id + '&deptName=' + val.name
				});
			},
			toDoctorlist() {
				uni.navigateTo({
					url: '/pages4/doctorlist/index'
				});
			},
			toDoctorlistByUnscramble() {
				uni.navigateTo({
					url: '/pages4/doctorlist/index?isUnscramble=1'
				});
			},
			toTjyf() {
				uni.navigateTo({
					url: '/pages5/ynzj/index'
				});
			},
			toDeptList() {
				uni.navigateTo({
					url: '/pages4/deptlist/index'
				});
			},
			tognkf() {
				uni.showToast({
					title: '功能开发中！',
					icon: 'none'
				})
			},
			tochufanglist() {
				uni.navigateTo({
					url: '/pages3/chufang/index'
				});
			},
			wxGetUserInfo() { //第一授权获取用户信息===》按钮触发
				let _this = this;
				// 获取用户信息
				uni.getUserProfile({
					desc: 'weixin',
					success: (infoRes) => {
						this.getUserHead = false
						uni.setStorageSync('nickName', infoRes.userInfo.nickName)
						uni.setStorageSync('avatarUrl', infoRes.userInfo.avatarUrl)
						this.avatarUrl = infoRes.userInfo.avatarUrl
						this.nickName = infoRes.userInfo.nickName
					}
				});
			},
			loginHX(userId) {
				var test_account = userId + '';
				let test_psword = ''
				if (uni.getStorageSync("test_psword")) {
					test_psword = uni.getStorageSync("test_psword")
				} else {
					this.gethx()
					test_psword = uni.getStorageSync("test_psword")
				}
				uni.setStorageSync("usrUserId", test_account)
				uni.setStorageSync("myUsername", test_account)
				this.$conn.open({
					apiUrl: this.$im.config.apiURL,
					user: test_account,
					pwd: test_psword,
					grant_type: "password",
					appKey: this.$im.config.appkey
				});
			},
			//加载更多
			loadMore(e) {
				var that = this;
				if (that.baseDeptId == 0) {
					if (e.detail.status == 'more') {
						that.message = 'loading';
						that.current = that.current + 1;
						console.log("that.current:" + that.current)
						setTimeout(() => {
							that.getDocList()
							if (that.hasNextPage) {
								that.message = 'more';
							} else {
								that.message = 'noMore';
							}
						}, 500);
					}
				} else {
					if (e.detail.status == 'more') {
						that.message = 'loading';
						that.deptCurrent = that.deptCurrent + 1;
						setTimeout(() => {
							that.getDocInfoBydeptId(that.baseDeptId)
							if (that.hasNextPage) {
								that.message = 'more';
							} else {
								that.message = 'noMore';
							}
						}, 500);
					}
				}

			},
			showWin() {
				this.winState = true;
				setTimeout(() => {
					let animation = this.animation;
					// 定义动画内容
					animation.translateX(0).step()
					// 导出动画数据传递给data层
					this.animationData = animation.export()
				}, 200)
			},
			hideWin() {
				let animation = this.animation;
				// 定义动画内容
				animation.translateX(this.windowWidth).step()
				// 导出动画数据传递给data层
				this.animationData = animation.export()
				setTimeout(() => {
					this.winState = false;
				}, 500)
			},
			getHspDeptList() {
				this.func.$request('wx/getHspDeptList.tz', {
					hspId: this.hspId,
					type: 1
				}, 'GET').then(res => {
					if (res.data.success = true) {
						let deptList = res.data.result
						if (deptList && deptList.length > 0) {
							this.deptList = deptList
						}
					}
				})

			},
			getBaselnfoList() {
				this.func.$request('wx/getBaseInfoList.tz.tz', {
					hspId: this.hspId
				}, 'GET', 'application/json').then(res => {
					if (res.data.success = true) {
						let baselnfoList = res.data.result
						this.baselnfoList = baselnfoList
						console.log('baselnfoList::', this.baselnfoList)
					}
				})
			},
			getHspNoticeList() {
				this.func.$request('wx/getHspNoticeList.tz', {
					hspId: this.hspId
				}, 'GET').then(res => {
					if (res.data.success = true) {
						let noticeList = res.data.result
						if (noticeList && noticeList.length > 0) {
							this.notice = noticeList[0].content
						}
					}
				})
			},
			//获取医生列表
			getDocList() {
				var that = this
				that.baseDeptId = 0
				that.func.$request('doctor/doctorlist.tz', {
					hospitalId: this.hspId,
					current: that.current
				}, 'GET').then(res => {
					if (res.data.success = true) {
						that.hasNextPage = res.data.result.hasNextPage;
						if (that.hasNextPage) {
							that.message = 'more';
						} else {
							that.message = 'noMore';
						}
						if (res.data.result.list.length > 0) {
							res.data.result.list.forEach(function(item, index) {
								that.allDocList.push(item);
							});
						}
						var uniques = [];
						var stringify = {};
						for (var i = 0; i < that.allDocList.length; i++) {
							var keys = Object.keys(that.allDocList[i]);
							keys.sort(function(a, b) {
								return (Number(a) - Number(b));
							});
							var str = '';
							for (var j = 0; j < keys.length; j++) {
								str += JSON.stringify(keys[j]);
								str += JSON.stringify(that.allDocList[i][keys[j]]);
							}
							if (!stringify.hasOwnProperty(str)) {
								uniques.push(that.allDocList[i]);
								stringify[str] = true;
							}
						}
						that.docList = uniques
					} else {
						that.message = 'noMore';
					}

				})


			},
			//跳转医生详情页
			getDocInfo(id, recNum) {
				var that = this;
				var docId = id;
				var recNum = recNum

				console.log("用户ID" + that.usrUserId)
				uni.navigateTo({
					url: '/pages4/doctor/index?docId=' + docId + '&usrUserId=' + that.usrUserId + '&recNum=' +
						recNum
				});
			},
			//点击搜索跳转搜索页面
			toSeach() {
				var that = this;
				uni.navigateTo({
					url: '/pages/search/index?usrUserId=' + that.usrUserId
				})
			},
			//点击科室获取医生列表
			getDocInfoBydeptId(id) {
				var that = this
				var storDeptId = uni.getStorageSync("baseDeptId")
				if (storDeptId != id) {
					that.deptCurrent = 1
				}
				that.baseDeptId = id;
				uni.setStorageSync("baseDeptId", that.baseDeptId)
				this.func.$request('doctor/doctorlist.tz', {
					hospitalId: this.hspId,
					baseDeptId: that.baseDeptId,
					current: that.deptCurrent
				}, 'GET').then(res => {
					if (res.data.success = true) {
						that.hasNextPage = res.data.result.hasNextPage;
						if (that.hasNextPage) {
							that.message = 'more';
						} else {
							that.message = 'noMore';
						}
						res.data.result.list.forEach(function(item, index) {
							that.deptDocList.push(item);
						});
						var uniques = [];
						var stringify = {};
						for (var i = 0; i < that.deptDocList.length; i++) {
							var keys = Object.keys(that.deptDocList[i]);
							keys.sort(function(a, b) {
								return (Number(a) - Number(b));
							});
							var str = '';
							for (var j = 0; j < keys.length; j++) {
								str += JSON.stringify(keys[j]);
								str += JSON.stringify(that.deptDocList[i][keys[j]]);
							}
							if (!stringify.hasOwnProperty(str)) {
								uniques.push(that.deptDocList[i]);
								stringify[str] = true;
							}
						}
						for (var i = uniques.length - 1; i >= 0; i--) {
							var deptId = uniques[i].deptId;
							if (deptId != that.baseDeptId) {
								uniques.splice(i, 1);
							}
						}
						that.docList = uniques;
					} else {
						that.message = 'noMore';
					}
				})

			},
			//跳转公益咨询页面
			toBenefit() {
				// var that = this;
				// uni.navigateTo({
				// 	url: '/pages/benefit/index?usrUserId=' + that.usrUserId
				// })
				uni.navigateTo({
					url: '/pages/about/index'
				})
			},
			toDaohang() {
				uni.navigateTo({
					url: '/pages/map/index'
				})
			},
			// userLogin(){
			// 	var that=this;
			// 	console.log(that.account+that.pwd)
			// 	uni.request({
			// 		url:that.wx+'/application-usrapp/login/in.tz?uname='+that.account+'&password='+that.pwd,
			// 		method:'POST',
			// 		header: {
			// 			'content-type': 'application/x-www-form-urlencoded'
			// 		},
			// 		success:function(res){
			// 			console.log(res.data)
			// 			if(res.data.success==true){
			// 				that.usrUserId=res.data.result.usrUserId+'';
			// 				that.tel=res.data.result.usrUserUname;
			// 				uni.setStorageSync("usrUserId",that.usrUserId)
			// 				uni.setStorageSync("myUsername",that.usrUserId);
			// 				var test_psword = 123456;
			// 				that.$conn.open({
			// 					apiUrl: that.$im.config.apiURL,
			// 					user: that.usrUserId,
			// 					pwd: test_psword,
			// 					grant_type: "password",
			// 					appKey: that.$im.config.appkey
			// 				});
			// 			}
			// 		}
			// 	})
			// }
		}
	};
</script>

<style lang="less">
	.zxwz {
		background: linear-gradient(90deg, rgba(255, 237, 213, 1) 0%, rgba(254, 249, 243, 1) 100%);
	}

	.win {
		position: fixed;
		width: 100%;
		height: 100vh;
		left: 0;
		top: 0;
		z-index: 20;
		background: rgba(0, 0, 0, 0.3);

		scroll-view {
			height: 100vh;
			background: #fff;

			view {
				height: 90rpx;
				line-height: 90rpx;
				border-bottom: 1rpx solid #EFEFEF;
				position: relative;
			}

			view.active::after {
				position: absolute;
				content: '';
				width: 65rpx;
				height: 10rpx;
				background: #74a6fd;
				left: 50%;
				margin-left: -32rpx;
				top: 65%;
			}
		}
	}

	#sticky-nav {
		position: -webkit-sticky;
		position: sticky;
		top: 0;
		left: 0;
		width: 100%;
		z-index: 10;
		background: #fff;
	}

	.search {
		height: 65rpx;
		background: #efefef;
		border-radius: 10rpx;

		image {
			width: 32rpx;
			height: 32rpx;
			margin-right: 10rpx;

		}
	}

	.screen image {
		width: 30rpx;
		height: 24rpx;
		margin-left: 10rpx;
	}

	.list>view {
		padding: 40rpx 0;
		border-top: 1rpx solid #efefef;

		.doctor {
			color: #74a6fd;

			.doctorv {
				width: 150rpx;

				image {
					width: 32rpx;
					height: 32rpx;
					margin-right: 10rpx;
				}
			}
		}
	}

	.list .head {
		height: 140rpx;

		image {
			width: 140rpx;
			height: 140rpx;
			border-radius: 50%;
		}

		.texts {
			height: 32rpx;
			bottom: -4rpx;

			text {
				display: inline-block;
				height: 32rpx;
				line-height: 32rpx;
				border-radius: 16rpx;
				background: #74a6fd;
				font-size: 22rpx;
				padding: 0 15rpx;
			}

			.text1 {
				background: #ff0000;
			}

			.text3 {
				background: #999999;
			}

			.text2 {
				background: #fec322;
			}

		}
	}

	.row {
		width: 94%;
		height: 160rpx;
		display: flex;
		align-items: center;
		margin: auto;
		justify-content: space-around;
		margin-top: 30rpx;
		
	}

	.row:first-child {
		margin-top: 0;
		padding-top: 30rpx;
	}

	/* 公共卡片 */
	.card {
		position: relative;
		width: 48%;
		height: 100%;
		border-radius: 8px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-left: 30rpx;
		padding-right: 20rpx;
		box-sizing: border-box;
	}

	/* 卡片内容 */
	.card-content {
		display: flex;
		flex-direction: column;
		justify-content: center;
	}

	.card-title {
		font-weight: bold;
	}

	.card-desc {
		font-size: 24rpx;
		margin-top: 8rpx;
	}

	/* 卡片图片 */
	.card-img {
		height: 55%;
		position: absolute;
		z-index: 9;
		bottom: 0;
		right: 0;
	}

	.card-bg {
		height: 60%;
		position: absolute;
		bottom: 0;
		z-index: 8;
		right: 0;
	}

	/* 各卡片专属样式 */
	.zxwz {
		background-color: transparent;
	}

	.zxwz .card-title {
		font-size: 36rpx;
		color: #AF7B56;
	}

	.zxwz .card-desc {
		color: rgba(87, 61, 34, 0.6);
	}

	.ffxz {
		background: linear-gradient(87deg, #FFD9D8, #FFF6F5);
	}

	.ffxz .card-title {
		font-size: 40rpx;
		color: rgba(180, 98, 91, 1);
	}

	.ffxz .card-desc {
		color: rgba(180, 98, 91, 0.6);
	}

	.ynzj {
		background: linear-gradient(90deg, rgba(237, 241, 250, 1) 0%, rgba(244, 249, 255, 1) 100%);
	}

	.ynzj .card-title {
		font-size: 40rpx;
		color: #6680A5;
	}

	.ynzj .card-desc {
		color: #6680A5;
	}

	.bgjd {
		background: linear-gradient(90deg, rgba(227, 243, 240, 1) 0%, rgba(244, 253, 252, 1) 100%);
	}

	.bgjd .card-title {
		font-size: 40rpx;
		color: #63A792;
	}

	.bgjd .card-desc {
		color: #63A792;
	}
	.rmks{
		background: url(../../static/images/ksbg.png);
	}
</style>